package com.hx.demo.serialize;

import com.alibaba.fastjson.JSON;

/**
 * @author Huathy
 * @date 2021-10-16 10:26
 * @description
 */
public class FastJsonSerializer implements ISerializer{
    @Override
    public <T> byte[] serialize(T obj) {
        return JSON.toJSONString(obj).getBytes();
    }

    @Override
    public <T> T deserialize(byte[] data, Class<T> clazz) {
        return (T)JSON.parseObject(new String(data),clazz);
    }
}
